package com.ate.testday03;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.TextView;

import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.Executors;

public class MainActivity extends AppCompatActivity {
    private TextView djs;
    int i=5;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        djs = (TextView) findViewById(R.id.djs);

        final Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
//                i--;
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        djs.setText(""+i--);
                    }
                });
                if (i==0){
                    timer.cancel();;
                }
            }
        },1000,1000);
    }
}
